<?php 
namespace Home\Controller;

// use \Think\Controller;

class ForgetPasswordController extends HomeController
{	
	public function getphone()
	{
		$this->display();
	}
	public function doajax()
	{
		$phone = I('post.phone');
		$user = M('user');
		$list = $user->where('phone='.$phone)->find();
		if($list) {
			$_SESSION['home_user']['forgetphone'] =$phone;

			$this->ajaxReturn(1);
		} else{
			$this->ajaxReturn(0);

		}
	}

	//执行找回页面
	public function securityPass() 
	{
		$this->display();
	}

	//执行修改操作
	public function save()
	{
		$phone = $_SESSION['home_user']['forgetphone'];
		$userpass = I('post.userpass3');
		// var_dump($userpass);
		$user = M('user');
		// $data['phone'] = $phone;
		$data['userpass'] = md5($userpass);

		if($user->where('phone='.$phone)->save($data)) {
			$this->success('密码修改成功请登录',U('home/index/index'));
		}
	}
}